package org.domeos.framework.api.consolemodel.deployment;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import org.domeos.framework.api.model.deployment.DeployCollection;
import org.domeos.util.StringUtils;

@ApiModel("创建服务对象")
public class DeployCollectionDraft {
	
	@ApiModelProperty(required = true , dataType = "string" , value = "*服务名称")
    private String name;
	@ApiModelProperty(hidden = true)
    private int id;
    @ApiModelProperty(required = true , dataType = "string" , value = "服务描述")
    private String description;
    @ApiModelProperty(required = true , dataType = "int" , value = "*产品树ID")
    private int treeId;
    @ApiModelProperty(hidden = true)
    private int creatorId;
    @ApiModelProperty(hidden = true)
    private int userId;

    public DeployCollectionDraft() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }


    public int getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(int creatorId) {
        this.creatorId = creatorId;
    }

    public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getTreeId() {
		return treeId;
	}

	public void setTreeId(int treeId) {
		this.treeId = treeId;
	}

	public String checkLegality() {
        String error = null;
        if (StringUtils.isBlank(name)) {
            error = "deploy collection name is blank";
        }
        return error;
    }

    public DeployCollection toDeployCollection() {
        DeployCollection deployCollection = new DeployCollection();
        deployCollection.setCreatorId(creatorId);
        deployCollection.setName(name);
        deployCollection.setDescription(description);
        deployCollection.setTreeId(treeId);
        return deployCollection;
    }
    
    
}
